package com.dyit.springcloud.ribbon.config.controller;

import com.dyit.springcloud.common.dto.HttpResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("/api/ribbon")
@Api("通过使用ribbon负载均衡发送server")
public class RibbonController {


    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/findAll")
    @ApiOperation("通过ribbon查询所有图书")
    public HttpResp findAll(){
        return restTemplate.getForEntity("http://springcloud-book/api/book/findAll",HttpResp.class).getBody();
    }
}
